package com.ruoyi.store.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.store.service.IStockOutDetailService;
import com.ruoyi.system.api.domain.store.StockOutDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stockOutDetail")
@Slf4j
public class StockOutDetailController extends BaseController {

    @Autowired
    private IStockOutDetailService stockOutDetailServiceImpl;

    @RequiresPermissions("store:stockOut:getOutDetail")
    @GetMapping(value = "/{orderId}")
    public AjaxResult list(@PathVariable("orderId") int orderId) {
        log.info("StockOutDetailController   list start......orderId:" + orderId);
        return AjaxResult.success(stockOutDetailServiceImpl.getOutStockDetail(orderId));
    }

    @RequiresPermissions("store:stockOut:list")
    @GetMapping(value = "getOutDetailByOutId/{outId}")
    public AjaxResult getOutDetailByOutId(@PathVariable("outId") int outId) {
        log.info("StockOutDetailController  getOutDetailByOutId start......outId:" + outId);
        return AjaxResult.success(stockOutDetailServiceImpl.getOutDetailByOutId(outId));
    }

    @RequiresPermissions("store:stockOutDetail:list")
    @RequestMapping("getStockOutDetailUseList")
    public TableDataInfo getStockOutDetailUseList(StockOutDetail stockOutDetail) {
        log.info("StockOutDetailController getStockOutDetailUseList params:{}", stockOutDetail);
//        startPage();
        List<StockOutDetail> stockOutDetailList = stockOutDetailServiceImpl.getStockOutDetailUseList(stockOutDetail);
        return getDataTable(stockOutDetailList);
    }


}
